$.ajaxPrefilter(function (options) {
  // console.log(options.url, 222222)
  // console.log(options.complete)
  // options.complete = function (respons) {
  //   console.log(respons, 12321)
  //   if (respons.responseJSON.message !== '身份认证失败！' && espons.responseJSON.status !== 0) {
  //     return (location.href = 'index.html')
  //   }
  // }
  if (!localStorage.getItem('token')) {
    if (options.url !== '/api/login') {
      return (location.href = '/login.html')
    }
  }

  var headers = {
    Authorization: localStorage.getItem('token')
  }
  options['headers'] = headers
  options.url = 'http://api-breakingnews-web.itheima.net' + options.url
  // console.log(options, 1111)
})
